package com.example.yls.demoa;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Path;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;

/**
 * Created by yls on 2019/5/10.
 */

public class MyView extends View {
    private Paint paint=new Paint();
    public MyView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        paint.setColor(Color.RED);
        paint.setStrokeWidth(2);
        paint.setAntiAlias(true);
        paint.setTextSize(20);
        paint.setStyle(Paint.Style.STROKE);

    }
    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        Bitmap bitmap=BitmapFactory.decodeResource(getResources(),
                R.drawable.dogs);
        canvas.drawBitmap(bitmap,0,0,paint);
        Matrix matrix=new Matrix();
        matrix.setRotate(90,150,150);
        canvas.drawBitmap(bitmap,matrix,paint);
        matrix.setRotate(180,150,150);
        canvas.drawBitmap(bitmap,matrix,paint);
        matrix.setRotate(270,150,150);
        canvas.drawBitmap(bitmap,matrix,paint);
 /*       Bitmap bitmap= BitmapFactory.decodeResource(getResources(),
                R.drawable.dog);
      canvas.drawBitmap(bitmap,0,0,paint);

        Matrix matrix=new Matrix();
        matrix.setScale(-1,1);
        matrix.postTranslate(300,0);
        canvas.drawBitmap(bitmap,matrix,paint);
        Matrix matrix2=new Matrix();
        matrix2.setScale(1,-1);
        matrix2.postTranslate(0,297);
        canvas.drawBitmap(bitmap,matrix2,paint);
        Matrix matrix3=new Matrix();
        matrix3.setScale(-1,-1);
        matrix3.postTranslate(300,297);
        canvas.drawBitmap(bitmap,matrix3,paint);*/
        /*canvas.drawColor(Color.BLUE);
        canvas.drawPoint(100,100,paint);
        // canvas.drawArc(100,100,400,400,0,90,true,paint);
         canvas.drawText("软件",100,100,paint);
         canvas.drawLine(100,100,400,400,paint);
         canvas.drawRect(100,100,400,400,paint);
         canvas.drawCircle(100,100,20,paint);
         Path path=new Path();
          paint.setStyle(Paint.Style.FILL);*/
       /*  path.moveTo(250,250);
         path.lineTo(300,250);
         path.lineTo(300,300);
         path.lineTo(250,300);
         canvas.drawPath(path,paint);*/
         /*path.moveTo(0,100);
         path.lineTo(300,100);
         path.lineTo(50,250);
         path.lineTo(150,0);
         path.lineTo(250,250);
         path.lineTo(0,100);
         canvas.drawPath(path,paint);*/
    }
}
